import requests
import db

# url = 'https://movie.douban.com/typerank'
url = 'https://movie.douban.com/j/chart/top_list'
my_params = {
    'type':25,
    'interval_id': '100:90',
    'action': '',
    'start': 0,
    'limit': 10
}
my_headers ={
    'user-agent':'Mozilla/5.0 (X11; Linux aarch64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.200 Safari/537.36 Qaxbrowser',
}
res = requests.get(url, params=my_params, headers=my_headers)
# print(res.text)
res_json = res.json()
print(res_json)
print(res.request.headers)
print(type(res_json))

exlist = []

for movie in res_json:
    exlist.append([
        movie.get('title'),
        movie.get('score'),
        movie.get('release_date')
    ])

for i in exlist:
    print(i)

db.insert_datas(exlist)